package me.yuxiaoyao.jpa.nativesql.mapper;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author kerryzhang on 2020/12/16
 */


public class DefaultSqlDateConverter implements SqlDateConverter {
    @Override
    public LocalDate sqlDateToLocalDate(java.sql.Date date) {
        return date.toLocalDate();
    }

    @Override
    public Date sqlDateToDate(java.sql.Date date) {
        return Date.from(date.toInstant());
    }

    @Override
    public java.util.Date sqlTimestampToDate(java.sql.Timestamp timestamp) {
        return java.util.Date.from(timestamp.toInstant());
    }

    @Override
    public LocalDateTime sqlTimestampToLocalDateTime(java.sql.Timestamp timestamp) {
        return timestamp.toLocalDateTime();
    }

}
